import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2024-12-02
 * Time: 13:23
 */
public class test3 {
    /*
    NewCoder BM13 判断一个链表是否是回文结构
    给定一个链表，请判断该链表是否为回文结构。
    回文是指该字符串正序逆序完全一致。
     */
    public boolean isPail (test2.ListNode head) {
        // write code here
        if(head==null || head.next==null){
            return true;
        }
        ArrayList<Integer> nums = new ArrayList();
        while(head!=null){
            nums.add(head.val);
            head = head.next;
        }
        int left  =0;
        int right = nums.size()-1;
        while(left<=right){
            int l = nums.get(left);
            int r = nums.get(right);
            if(l != r){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
